package de.lns.entities.effect;

import de.lns.entities.mobs.Mob;
/**
 * 
 * @author Jascha
 *
 */
public class InstantDamageEffect extends InstantEffect {

	private Damage damage;
	private double dmgamount;
	private double critchance;
	private Mob mob;
	
	/**
	 * 
	 * @param entity The Mob the damage should be applied on.
	 * @param damage The type of damage that should be applied.
	 * @param dmgamount The amount of damage that should be applied.
	 * @param critchance The critical strike chance this effect should have.
	 */
	public InstantDamageEffect(Effectable entity,Damage damage, double dmgamount, double critchance) {
		super(entity);
		this.critchance=critchance;
		this.damage=damage;
		this.dmgamount=dmgamount;
		this.mob=(Mob)entity;
	}
	/**
	 * The actual Damage apply.
	 * 
	 */
	@Override
	protected void onUpdate() {
		boolean crit = false;
		if(Math.random()*100>critchance)
			crit=true;
		this.mob.getDamage(damage,dmgamount, crit);
		
	}

}
